package tests

import (
	"testing"

	"notabug.org/Umnik/GoAndroidSDK/v2/components/sdk/platformTools/adb"
)

func newAdb(t *testing.T) *adb.Adb {
	t.Helper()
	adbTool, err := adb.NewAdbFromSdk(*newSdk(t, t.Name()))
	if !testErr(t, t.Name(), err) {
		return nil
	}
	return adbTool
}

func TestDevices(t *testing.T) {
	adbTool := newAdb(t)
	devices := adbTool.ConnectedDevices()
	if len(devices) < 1 {
		t.Error("No any device/emulator found")
	} else {
		for i, val := range devices {
			if len(val.Serial()) < 12 {
				t.Errorf("bad device serial: %q (device %d of %d)", val.Serial(), i+1, len(devices))
			}
		}
	}
}
